/*
 * ExitAction.java
 *
 * Created on 11. b�ezen 2007, 21:39
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
package main.controller.actions.observer;

import main.Main;
import main.MainFrame;

import java.awt.event.ActionEvent;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * @author danecek
 */
public class ExitAction extends AbstractObserverAction {

    private static Logger logger = Logger.getLogger(ExitAction.class.getName());

    private static ExitAction instance;

    /**
     * @return the instance
     */
    public static ExitAction getInstance() {
        if (instance == null) {
            instance = new ExitAction();
        }
        return instance;
    }

    /**
     * Creates a new instance of ExitAction
     */
    private ExitAction() {
        super("Exit");
    }

    public void actionPerformed(ActionEvent e) {
        try {
            Main.getInstance().getFacade().exit();
        } catch (Exception ex) {
            logger.log(Level.SEVERE, null, ex);
            MainFrame.getInstance().showErr(ex);
        }
        System.exit(0);
    }

    @Override
    boolean isEnabledInState() {
        return true;
    }
}
